package com.agino.springboot.learn.ddd.product;

public class ProductMapper {
    public static OrderProduct toOrderProduct(InventoryProduct inventoryProduct) {
        OrderProduct orderProduct = new OrderProduct();
        orderProduct.setId(inventoryProduct.getId());
        orderProduct.setName(inventoryProduct.getName());
        orderProduct.setQuantity(0);  // 设置数量为0，因为此时是从订单领域转换到库存领域的模型
        return orderProduct;
    }

    public static InventoryProduct toInventoryProduct(OrderProduct orderProduct) {
        InventoryProduct inventoryProduct = new InventoryProduct();
        inventoryProduct.setId(orderProduct.getId());
        inventoryProduct.setQuantity(orderProduct.getQuantity());
        return inventoryProduct;
    }
}
